#!/usr/bin/python3
import pymysql

db = pymysql.connect(user='root', passwd="123123",host="localhost")
db.autocommit(True)
cur = db.cursor()
c_db = "create database sanle_1"

cur.execute(c_db)
c_tb = "create table sanle_1.student(id int,name varchar(10),age int,phone_num decimal(20),address varchar(60),major varchar(20),primary key(id))"

cur.execute(c_tb)
i_data = "insert into sanle_1.student (id,name,age,phone_num,address,major) values (1,'cali',33,18908495097,'yongzhou','computer science')"
cur.execute(i_data)

rose_num = 18012345678
rose_add = 'changde'
rose_major = 'english'
rose_data = "insert into sanle_1.student (id,name,age,phone_num,address,major) values (2,'rose',23,{num},'{add}','{major}')".format(num=rose_num,add=rose_add,major=rose_major)
cur.execute(rose_data)

u_data = "insert into sanle_1.student (id,name,age,phone_num,address,major) values (3,'jack',33,18908495097,'yueyang','computer science')"
cur.execute(u_data)

s_sql = "select * from sanle_1.student"
cur.execute(s_sql)
all_data = cur.fetchall()
for i in all_data:
    print(i)